Skip to content

Leaves-Yasmin #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Leaves-Yasmin #41

wants to merge 1 commit into from

Conversation

YasminM11
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these work, but see my notes on the time complexity. Overall nice work!

index_1 = 0
array.times do
if list[index_1] == list[index_1 + 1]
list.delete_at(index_1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually delete_at will remove the element at index_1 by shifting all the subsequent elements left by one index. So it's an O(n) method. Since you have it nested in a loop running n times. This is actually an O(n2) method.

end

# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: o(n^2)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually O(mn) where m is the length of the strings and n is the number of strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants